From bcad6d85980bf6a1e8298408994930fda92a3ce1 Mon Sep 17 00:00:00 2001 From: 0 Date: Sat, 30 Oct 1999 23:07:18 +0000 Subject: [PATCH] (ReadImage): lets get the offset right. This will let transparent gifs 1999-10-30 (ReadImage): lets get the offset right. This will let transparent gifs work. Right now, gifs with transparency, both interlaced and non-interlaced, seem to work perfectly fine. I haven't tried grayscale gifs yet, and I seem to be getting offset in my RGB buffer with non-alpha gifs. )-: This leads to pretty, but incorrect, images. -Jonathan --- gdk-pixbuf/ChangeLog | 2 ++ gdk-pixbuf/io-gif.c | 32 ++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index abea322107..af84ad8968 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -3,6 +3,8 @@ * src/io-gif.c: Some more work. Now it generates a gdk_pixbuf of the right size, at a minimum, even if the image is squished and the wrong color. + (ReadImage): lets get the offset right. This will let transparent + gifs work. 1999-10-28 Jonathan Blandford diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c index 5f3d3cf0f2..d3bbcbfedf 100644 --- a/gdk-pixbuf/io-gif.c +++ b/gdk-pixbuf/io-gif.c @@ -74,7 +74,6 @@ struct _GifContext unsigned int aspect_ratio; int gray_scale; GdkPixbuf *pixbuf; - guchar used_cmap[3][256]; Gif89 gif89; }; @@ -367,7 +366,6 @@ ReadImage (FILE *file, guchar c; gint xpos = 0, ypos = 0, pass = 0; gint v; - gint i, j; /* ** Initialize the Compression routines @@ -377,6 +375,7 @@ ReadImage (FILE *file, return; } + g_print ("c = %d\n", c); if (LWZReadByte (file, TRUE, c) < 0) { /*g_message (_("GIF: error while reading\n"));*/ return; @@ -388,22 +387,20 @@ ReadImage (FILE *file, context->width, context->height); - for (i = 0, j = 0; i < ncols; i++) { - context->used_cmap[0][i] = cmap[0][i]; - context->used_cmap[1][i] = cmap[1][i]; - context->used_cmap[2][i] = cmap[2][i]; - } - dest = gdk_pixbuf_get_pixels (context->pixbuf); while ((v = LWZReadByte (file, FALSE, c)) >= 0) { +// g_print ("in inner loop: xpos = %d, ypos = %d\n", xpos, ypos); if (context->gif89.transparent) { - temp = dest + ( (ypos * len) + xpos ) * 2; - *temp = (guchar) v; - *(temp+1) = (guchar) ((v == context->gif89.transparent) ? 0 : 255); + temp = dest + (ypos * len + xpos) * 4; + *temp = cmap [0][(guchar) v]; + *(temp+1) = cmap [1][(guchar) v]; + *(temp+2) = cmap [2][(guchar) v]; + *(temp+3) = (guchar) ((v == context->gif89.transparent) ? 0 : 65535); } else { - - temp = dest + (ypos * len) + xpos; - *temp = (guchar) v; + temp = dest + (ypos * len + xpos) * 3; + *temp = cmap [0][(guchar) v]; + *(temp+1) = cmap [1][(guchar) v]; + *(temp+2) = cmap [2][(guchar) v]; } xpos++; @@ -448,8 +445,14 @@ ReadImage (FILE *file, } fini: + ypos = 0; +/* while (ReadOK (file, &c, 1) >= 0) + ypos++; + g_print ("ypos%d\n", ypos);*/ +/* if (LWZReadByte (file, FALSE, c) >= 0) g_print ("GIF: too much input data, ignoring extra...\n"); +*/ } /* Shared library entry point */ @@ -516,6 +519,7 @@ image_load (FILE *file) } for (;;) { + g_print ("in loop\n"); if (!ReadOK (file, &c, 1)) { /*g_message (_("GIF: EOF / read error on image data\n"));*/ return context->pixbuf; -- 2.30.2